Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

289
Views
esperar a que responda la llamada api después de desmontar el componente | vue.js

Tengo un método (doSomething) que se llamará en estado montado y también tengo un CTA para desmontar el componente. Antes de que finalice la llamada en espera si el usuario desmonta el componente con CTA posterior, el controlador aún regresa al componente desmontado. Cómo abortar la respuesta que regresa al componente.

Componente Vue:

 doSomething(){ let data = await someApiCall(); console.log(data) }

Tienda.js(vuex)

 someApiCall(){ axios.get("apicall").then(res => res); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

En lugar de abandonar, puede evitar que se pueda hacer clic en 'desmontar CTA' en primer lugar, hasta que el método doSomething() haya completado su búsqueda.

 export default { data() { return { isFetching: false, } }, methods: { async doSomething() { this.isFetching = true let data = await someApiCall() }, myUnmount() { // Do your unmount }, }, async mounted(){ await this.doSomething() this.isFetching = false } }

Y luego vincule esto a la CTA;

 <button @click="myUnmount()" :disabled="isFetching">Unmount</button>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!